package com.itheima.day14.day14work3;

public class Ticket implements Runnable {
    private int count =1000;
    private final Object obj=new Object();
    @Override
    public void run() {
        while (true) {
            synchronized (obj){
                if (count<=0){
                    break;
                }
                System.out.println(Thread.currentThread().getName()+"售卖第"+count+"张票");
                count--;
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
